package com.zzq.mapper;


import com.zzq.pojo.Message;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface MessageMapper {

    @Select("select * from message ORDER BY create_at DESC")
    List<Message> getMessageList();


    @Delete("delete from message where id=#{id}")
    void deleteMessage(int id);

    @Insert("insert into message (type,message_content,create_at) values (#{type},#{messageContent},now())")
    void addMessage(Message message);

    @Insert("insert into message (type,message_content,create_at) values (1,#{messageContent},now())")
    void pushMessage(String message);

    @Select("select * from message ORDER BY create_at DESC LIMIT #{page},#{size}")
    List<Message> getNewMessageList(int page, int size);

    @Select("select * from message where id=#{id}")
    Message getNoticeById(int id);
}
